// pages/classify/index.js
Page({

    data: {
        iconList: [
            {
                id: 0,
                img: '../../assets/class-icon/zhushi.png',
                text: "主食类"
            },
            {
                id: 1,
                img: '../../assets/class-icon/roulei.png',
                text: "肉蛋类"
            },
            {
                id: 2,
                img: '../../assets/class-icon/doulei.png',
                text: "大豆类"
            },
            {
                id: 3,
                img: '../../assets/class-icon/shucai.png',
                text: "蔬菜类"
            },
            {
                id: 4,
                img: '../../assets/class-icon/shuiguo.png',
                text: "水果类"
            },
            {
                id: 5,
                img: '../../assets/class-icon/niunai.png',
                text: "奶类"
            },
            {
                id: 6,
                img: '../../assets/class-icon/you.png',
                text: "油脂类"
            },
            {
                id: 7,
                img: '../../assets/class-icon/jianguo.png',
                text: "坚果类"
            },
            {
                id: 8,
                img: '../../assets/class-icon/tiaowei.png',
                text: "调味类"
            },
            {
                id: 9,
                img: '../../assets/class-icon/yinliao.png',
                text: "饮料类"
            },
            {
                id: 10,
                img: '../../assets/class-icon/lingshi.png',
                text: "零食类"
            },
            {
                id: 11,
                img: '../../assets/class-icon/qita.png',
                text: "其他类"
            },
        ]
    },
    toSearch() {
        wx.navigateTo({
            url: '../search-view/index?param=1',
        })
    },
    //跳转列表
    onList(event) {
        const { id } = event.currentTarget.dataset
        wx.navigateTo({
            url:`../food-list/index?type=${ id }`
        })
    },
    onShow() {
        if (typeof this.getTabBar === 'function' &&
            this.getTabBar()) {
            this.getTabBar().setData({
                current: 1
            })
        }
    },
})